package com.sx.zongzhi.presenter;

import android.content.Context;

import com.sx.zongzhi.bean.NewSocietyOrganizationBean;
import com.sx.zongzhi.modle.ApiManager;
import com.sx.zongzhi.modle.HeadParamBean;
import com.sx.zongzhi.net.BaseCallBack;
import com.sx.zongzhi.net.BasePageListBean;
import com.sx.zongzhi.net.BaseResult;
import com.sx.zongzhi.utils.BaseUtil;
import com.sx.zongzhi.view.INewSocietyOrganizationView;

import java.util.Map;

/**新社会组织
 * Created by admin on 2017/12/8.
 */

public class NewSocietyOrganizationPest {
    private INewSocietyOrganizationView iNewSocietyOrganizationView;

    public NewSocietyOrganizationPest( INewSocietyOrganizationView iNewSocietyOrganizationView) {
        this.iNewSocietyOrganizationView=iNewSocietyOrganizationView;
    }

    /**
     *searchNewSocietyOrganizationsVo.name	否	string	社会组织名称
     searchNewSocietyOrganizationsVo.type.id	否	string	社会组织类型id
     searchNewSocietyOrganizationsVo.address	否	string	社会组织地址
     searchNewSocietyOrganizationsVo.legalPersonName	否	string	负责人姓名
     searchNewSocietyOrganizationsVo.legalSafePerson	否	string	治保负责人姓名
     searchNewSocietyOrganizationsVo.legalPersonTelephone	否	string	负责人电话号码
     searchNewSocietyOrganizationsVo.legalPersonMobileNumber	否	string	负责人手机号码
     searchNewSocietyOrganizationsVo.legalSafePersonTelephone	否	string	治保负责人电话号码
     searchNewSocietyOrganizationsVo.legalSafePersonMobileNumber	否	string	治保负责人手机号码
     searchNewSocietyOrganizationsVo.registrationManagementCode	否	string	登记管理机关代码
     searchNewSocietyOrganizationsVo.moneySource	否	string	资金来源
     searchNewSocietyOrganizationsVo.registrationNumber	否	string	登记证号码
     searchNewSocietyOrganizationsVo.unifiedSocialCreditCode	否	string	统一社会信用代码
     searchNewSocietyOrganizationsVo.haveOverSea	否	int	是否海外背景(0:否,1:是)
     orgId	否	string	网格id(根据网格筛选:不填写默认为当前登陆用户所在网格)
     * @param context
     * @param page
     * @param rows
     * @param orgId
     */
    public void getNewSocietyOrganizationList(Context context, int page, int rows, String name,
                                              String typeId, String address, String legalPerson,
                                              String legalSafePerson, String legalPersonTelephone,
                                              String legalPersonMobileNumber,String legalSafePersonTelephone,
                                              String legalSafePersonMobileNumber, String registrationManagementCode,
                                              String moneySource,String registrationNumber,
                                              String unifiedSocialCreditCode,int haveOverSea,String orgId){
        Map<String,Object> map = HeadParamBean.getHead(context);
        map.put("page", page);
        map.put("rows", rows);
        if (!BaseUtil.isEmpty(name)){
            map.put("searchNewSocietyOrganizationsVo.name",name);
        }
        if (!BaseUtil.isEmpty(typeId)){
            map.put("searchNewSocietyOrganizationsVo.type.id",typeId);
        }
        if (!BaseUtil.isEmpty(address)){
            map.put("searchNewSocietyOrganizationsVo.address",address);
        }
        if (!BaseUtil.isEmpty(legalPerson)){
            map.put("searchNewSocietyOrganizationsVo.legalPerson",legalPerson);
        }
        if (!BaseUtil.isEmpty(legalSafePerson)){
            map.put("searchNewSocietyOrganizationsVo.legalSafePerson",legalSafePerson);
        }
        if (!BaseUtil.isEmpty(legalPersonTelephone)){
            map.put("searchNewSocietyOrganizationsVo.legalPersonTelephone",legalPersonTelephone);
        }
        if (!BaseUtil.isEmpty(legalPersonMobileNumber)){
            map.put("searchNewSocietyOrganizationsVo.legalPersonMobileNumber",legalPersonMobileNumber);
        }
        if (!BaseUtil.isEmpty(legalSafePersonTelephone)){
            map.put("searchNewSocietyOrganizationsVo.legalSafePersonTelephone",legalSafePersonTelephone);
        }
        if (!BaseUtil.isEmpty(legalSafePersonMobileNumber)){
            map.put("searchNewSocietyOrganizationsVo.legalSafePersonMobileNumber",legalSafePersonMobileNumber);
        }
        if (!BaseUtil.isEmpty(registrationManagementCode)){
            map.put("searchNewSocietyOrganizationsVo.registrationManagementCode",registrationManagementCode);
        }
        if (!BaseUtil.isEmpty(moneySource)){
            map.put("searchNewSocietyOrganizationsVo.moneySource",moneySource);
        }
        if (!BaseUtil.isEmpty(registrationNumber)){
            map.put("searchNewSocietyOrganizationsVo.registrationNumber",registrationNumber);
        }
        if (!BaseUtil.isEmpty(unifiedSocialCreditCode)){
            map.put("searchNewSocietyOrganizationsVo.unifiedSocialCreditCode",unifiedSocialCreditCode);
        }
        if (haveOverSea == 1){
            map.put("searchNewSocietyOrganizationsVo.haveOverSea",haveOverSea);
        }
        if (!BaseUtil.isEmpty(orgId)){
            map.put("orgId",orgId);
        }
        new ApiManager().getNewSocietyOrganizationList(map, new BaseCallBack<BaseResult<BasePageListBean<NewSocietyOrganizationBean>>>() {
            @Override
            public void onSuccess(BaseResult<BasePageListBean<NewSocietyOrganizationBean>> response) {
                iNewSocietyOrganizationView.getNewSocietyOrganizationListSuccess(response.getData().permission,response.getData().rows,response.getData().getTotal());
            }
            @Override
            public void onFailures(String message) {
                iNewSocietyOrganizationView.showError(message);
            }
        });
    }

}
